package stream.Demo03;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Author Miku
 * @Create 2021/4/29 14:39
 * 使用文件字节流实现文件的复制
 */
public class Test {
    public static void main(String[] args) throws IOException {
        //1.创建流
        //1.1 文件字节输入流
        FileInputStream fis = new FileInputStream("e:\\2233.jpg");
        //1.2 文件字节输出流
        FileOutputStream fos = new FileOutputStream("e:\\test.jpg");
        //2.一边读取一边写
        byte[] bytes = new byte[1024];
        int count = 0;
        while ((count = fis.read(bytes)) != -1) {
            fos.write(bytes, 0 ,count);
        }
        //3.关闭
        fis.close();
        fos.close();
        System.out.println("执行完毕");
    }
}
